package com.keye.common.servlet;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.view.AbstractUrlBasedView;
import org.springframework.web.servlet.view.InternalResourceViewResolver;

@Component
public class MyInternalResourceViewResolver extends InternalResourceViewResolver{

	public static final String NOT_URL_PREFIX = "not:";
	
	protected AbstractUrlBasedView buildView(String viewName) throws Exception {
		if(viewName.startsWith(NOT_URL_PREFIX)){
			//viewName = viewName.substring(NOT_URL_PREFIX.length());
			AbstractUrlBasedView au = super.buildView(viewName);
			au.setUrl(viewName.substring(NOT_URL_PREFIX.length()));
			return au;
		}
		return super.buildView(viewName);
	}
	
	@Override
	@Value("/WEB-INF/jsp/")
	public void setPrefix(String prefix) {
		// TODO Auto-generated method stub
		super.setPrefix(prefix);
	}
	@Override
	@Value(".jsp")
	public void setSuffix(String suffix) {
		// TODO Auto-generated method stub
		super.setSuffix(suffix);
	}
}
